#define GET_IDX(x)	x[0]%NUM_KEYS
#define NUM_KEYS	4
#define STRING_LENGTH	256

struct str_info {
	char str[STRING_LENGTH];
	void *ptr;			//information pointer to the actual data 
	struct str_info *next;		//for create a list of the info structs in a bucket.
};

class my_index {
	
	struct str_info* info[NUM_KEYS];
	class my_index *next;
	
	public:
		my_index();
		int insert_key(char *name, void *ptr);
		void *get_key(char *string);
		~my_index();


//??? later	int get_keys(string);

//??? later	int delete_key(string);

};

my_index :: my_index()
{
	int i=0;

	// initialize all the info structs to NULL
	for(i=0; i<NUM_KEYS; i++)
		info[i]=NULL;

}

int my_index :: insert_key(char *name, void *data)
{
	int index = GET_IDX(name);
	str_info *temp;

	temp = new str_info;
	strcpy(temp->str, name);
	temp->ptr = data;

	// Adding to the starting of the list
	temp->next = info[index];
	info[index] = temp;
	return(0);

}

void* my_index :: get_key (char *name)
{
	int index = GET_IDX(name);
	str_info *temp = info[index];

	while(temp != NULL)
	{
		if(!strcmp(name, temp->str))
		{
			return(temp->ptr);
		}
		else
		{
			DBGPRINTF("temp is %p\n", temp);
			temp=temp->next;
		}
		
	}

	return(NULL);
}

my_index :: ~my_index()
{
	int i=0;
	str_info *node, *next;

	// initialize all the info structs to NULL
	for(i=0; i<NUM_KEYS; i++)
	{
		node = info[i];
		while (node!=NULL)
		{
			next = node->next;
			delete(node);
			node = next;
		}

	}
}

